package view;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import model.Matriz;

public class Vista extends JFrame{

	private JFrame janela;
	private JPanel painel;
	private JTextArea text;
	private Dimension d;
	private Insets i;
	int altura,largura;
	private JButton start;
	
	public Vista(){
		
		text=new JTextArea();
		painel=new JPanel();
		janela=new JFrame("Elementos Finitos");
		
		painel.setLayout(new GridLayout(2,1));
		painel.add(text);
		
		d=Toolkit.getDefaultToolkit().getScreenSize();
		i=Toolkit.getDefaultToolkit().getScreenInsets(janela.getGraphicsConfiguration());
		largura=(d.width-i.left-i.right);
		altura=(d.height-i.top-i.bottom);
		janela.setSize(largura/3,altura/3);
		janela.setLocation(largura/2-janela.getWidth()/2,altura/2-janela.getHeight()/2);
		janela.add(painel);
		janela.setVisible(true);
		janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	public JFrame getJanela(){
		return this.janela;
	}
	
	public JButton getBotao(){
		return start;
	}
	
	public void exibir(Matriz m){
		for(int i=0;i<m.getM();i++){
			text.setText(text.getText()+m.getValor(i)+'\n');
		}
		janela.repaint();
	}
	
	public static void main(String[] args) {
		new Vista();
	}
	
	static final long serialVersionUID = 0;
}
